<?php

// General Functions.

function __autoload ($class)
{
	if (!class_exists($class)) {
		$class = str_replace('_', '/', $class) . '.php';
		require_once FORM_PATH . $class;
	}
}


function array_to_object ($a)
{
	return is_array($a) ? (object)array_map(__FUNCTION__, $a) : $a;
}

/**
 * Check if the value is empty after removing spaces from the input.
 * If it is empty then return the default value, else the passed value.
 *
 * @param mixed $a  Value that is being tested.
 * @param mixed $b  Default value used if empty.
 * @return mixed
 */
function defvalue ($a, $b = false)
{
	$a = trim($a);
	return (!empty($a)) ? $a : $b;
}

